//
//  MYCommonButton.m
//  MobaoInteraction
//
//  Created by a on 2019/12/28.
//  Copyright © 2019 mobao. All rights reserved.
//

#import "MYCommonButton.h"

@implementation MYCommonButton

- (instancetype)initWithBtnFrame:(CGRect)BtnFrame andImageFrame:(CGRect)imageFrame andTitleTop:(CGFloat)titleTop {
    self = [super initWithFrame:BtnFrame];
    if (self) {
        [self createImageFrame:imageFrame andTitleTop:titleTop];
    }
    return self;
}

- (void)createImageFrame:(CGRect)imageFrame andTitleTop:(CGFloat)titleTop {
    self.buttonImage = [[MyImageView alloc] initWithFrame:imageFrame];
    self.buttonImage.centerX = self.width/2;
    [self addSubview:self.buttonImage];
    
    self.buttonLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, titleTop, self.width, MY_SCALE_HEIGHT(16))];
    self.buttonLabel.font = MY_SCALE_FONT(13);
    self.buttonLabel.textColor = MyColor(@"#5F5F6B");
    self.buttonLabel.textAlignment = NSTextAlignmentCenter;
    [self addSubview:self.buttonLabel];
}


- (void)addTarget:(id)target action:(SEL)action forControlEvents:(UIControlEvents)controlEvents {
    [super addTarget:target action:action forControlEvents:controlEvents];
}

- (void)setCornerRadius:(CGFloat)radius {
    self.layer.cornerRadius = radius;
    self.clipsToBounds = true;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
